[XEN] Change microcode_update function interface inside Xen.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 5 Oct 2006 15:38:30 +0000 (16:38 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 5 Oct 2006 15:38:30 +0000 (16:38 +0100)
Confine the knowledge that the buffer gets accessed without use of
proper guest handle accessors to a single file.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/arch/x86/microcode.c
xen/arch/x86/platform_hypercall.c

index 9c4b4d66f8414fd911a35ecb9a59d7a600150821..3dcac7d124cebdc87fb2cebe5b3a675ab29c530e 100644 (file)
@@ -455,7 +455,7 @@ out:
        return error;
 }
 
-int microcode_update(void *buf, unsigned long len)
+int microcode_update(XEN_GUEST_HANDLE(void) buf, unsigned long len)
 {
        int ret;
 
@@ -464,10 +464,15 @@ int microcode_update(void *buf, unsigned long len)
                return -EINVAL;
        }
 
+       if (len != (typeof(user_buffer_size))len) {
+               printk(KERN_ERR "microcode: too much data\n");
+               return -E2BIG;
+       }
+
        mutex_lock(&microcode_mutex);
 
-       user_buffer = (void __user *) buf;
-       user_buffer_size = (int) len;
+       user_buffer = buf.p;
+       user_buffer_size = len;
 
        ret = do_microcode_update();
 
index 098c8471122aa70bccbf35236608886388ae60ae..1b886caab2d15a682521152aa18adc29867a763e 100644 (file)
@@ -104,8 +104,8 @@ long do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
 
     case XENPF_microcode_update:
     {
-        extern int microcode_update(void *buf, unsigned long len);
-        ret = microcode_update(op->u.microcode.data.p,
+        extern int microcode_update(XEN_GUEST_HANDLE(void), unsigned long len);
+        ret = microcode_update(op->u.microcode.data,
                                op->u.microcode.length);
     }
     break;